eratic / sites / fav / src / pages / [kind].astro
203 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
/**
 * One page per kind: /books/, /films/, /music/, /objects/, /other/.
 *
 * Single-segment routes, while individual entries live at /<year>/<slug>/, so
 * these can never collide with [...slug].astro — every path either route
 * produces is listed explicitly at build time.
 */
import Base from '@eratic/core/layouts/Base.astro';
import EntryList from '@eratic/core/components/EntryList.astro';
import { allFavs, favPath, favKicker } from '../lib/entries';
import { KINDS, KIND_PLURAL, type Kind } from '../content.config';

export async function getStaticPaths() {
	const favs = await allFavs();
	return KINDS.filter((kind) => favs.some((fav) => fav.data.kind === kind)).map((kind) => ({
		params: { kind: KIND_PLURAL[kind] },
		props: { kind },
	}));
}

const { kind } = Astro.props as { kind: Kind };
const favs = (await allFavs()).filter((fav) => fav.data.kind === kind);
const plural = KIND_PLURAL[kind];

const listed = favs.map((fav) => ({
	path: favPath(fav),
	title: fav.data.title,
	summary: fav.data.summary,
	pubDate: fav.data.pubDate,
	kicker: favKicker(fav),
}));
---

<Base site="fav" title={plural} description={`Favourite ${plural}.`} path={`/${plural}/`}>
	<header class="intro">
		<p class="eyebrow"><a href="/">fav</a></p>
		<h1>{plural}</h1>
	</header>

	<EntryList entries={listed} />
</Base>

<style>
	.intro {
		margin-block: var(--space-xl) var(--space-2xl);
		display: flex;
		flex-direction: column;
		gap: var(--space-2xs);
	}

	.intro h1 {
		font-family: var(--font-prose);
		font-size: var(--step-3);
		font-weight: 600;
		line-height: 1.05;
		letter-spacing: -0.02em;
		font-optical-sizing: auto;
	}

	.eyebrow a {
		color: inherit;
		text-decoration: none;
	}

	.eyebrow a:hover {
		color: var(--ink);
	}
</style>

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/eratic.git